package DomainLayer;
import java.util.ArrayList;

public class UserCollection
{

    private ArrayList<User> users;
    private static UserCollection instance;

    private UserCollection()
    {
        users= new ArrayList<User>();
        //default admin user which the access in the system at the beggining
        users.add(new Manager("admin","123", "Company Owner"));
    }
    
    //@return only one object of the class UserCollection.
    public static UserCollection getInstance()
    {
        if(instance==null)
        {
            instance=new UserCollection();
        }
        return instance;
        }
    
    public void addManager(String id, String password, String name)
    {
        Manager manager= new Manager(id, password, name);
        users.add(manager);
    }
    
    public void addAssistant(String id, String password, String name)
    {
        Assistant assistant =new Assistant(id, password, name);
        users.add(assistant);
    }
    
    //@return user according its unique ID number.
    public User findUser(String id)
    {
        for(User user : users)
        {
            if(user.getID().equals(id))
            return user;
        }
        return null;
    }
    
    public void deleteUser(String id)
    {
        users.remove(findUser(id));
    }
}
